/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package utils;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 *
 * @author pmchanh
 */
public class Misc {

    /**
     * Convert current date time to string
     * @return
     */
    public static String getDatetimeToString() {
          String kq = "";
          TimeZone zone = TimeZone.getTimeZone("GMT+07:00");

          Calendar  cal = Calendar.getInstance();
          cal.setTimeZone(zone);
          //Calendar  cal = GregorianCalendar.getInstance(timeZone2);
          Date datetime = new Date();
          cal.setTime(datetime);
          int year = cal.get(Calendar.YEAR);
          int month = cal.get(Calendar.MONTH)+1;
          int date = cal.get(Calendar.DAY_OF_MONTH);
          int time = cal.get(Calendar.HOUR_OF_DAY);
          int minute = cal.get(Calendar.MINUTE);
          int second = cal.get(Calendar.SECOND);

          kq += date < 10 ? "0" + date :"" + date + "/";
          kq +=month < 10 ? "0" + month:"" + month;
          kq += "/" + year + " ";

          kq += time < 10   ? "0" + time  +":" :"" + time + ":";
          kq += minute < 10 ? "0" + minute+":" :"" +minute+ ":";
          kq += second < 10 ? "0" + second:second;

          return kq;
    }
}
